package com.ld.control.business.process.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ld.control.business.equipment.service.EquipmentService;
import com.ld.control.business.equipment.vo.resp.EquipmentRespVo;
import com.ld.control.business.process.mapper.ProcessNodeTmpMapper;
import com.ld.control.business.process.mapper.ProcessNodeParamTmpMapper;
import com.ld.control.business.process.model.ProcessNodeParamTmpModel;
import com.ld.control.business.process.model.ProcessNodeTmpModel;
import com.ld.control.business.process.service.ProcessNodeTmpService;
import com.ld.control.business.process.vo.internal.LineInfo;
import com.ld.control.business.process.vo.internal.NodeInfo;
import com.ld.control.business.process.vo.internal.node.CustomNode;
import com.ld.control.business.process.vo.internal.node.EquipmentNode;
import com.ld.control.common.CommonConstant;
import com.ld.control.common.NodeParamConstant;
import com.ld.control.sysenum.MethodParamTypeEnum;
import com.ld.control.sysenum.NodeParamUseTypeEnum;
import com.ld.control.sysenum.ProcessNodeNameEnum;
import com.ld.control.utils.JWTUtils;
import com.ld.control.utils.VariableExampleUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

import java.util.*;

/**
 * <p>
 * 任务流程节点模板表 服务实现类
 * </p>
 *
 * @author wangfeng
 * @since 2024-04-24
 */
@Slf4j
@Service
public class ProcessNodeTmpServiceImpl extends ServiceImpl<ProcessNodeTmpMapper, ProcessNodeTmpModel> implements ProcessNodeTmpService {

    @Autowired
    private JWTUtils jwtUtils;

    @Autowired
    private ProcessNodeTmpMapper processNodeTmpMapper;

    @Autowired
    private ProcessNodeParamTmpMapper processNodeParamTmpMapper;

    @Autowired
    private EquipmentService equipmentService;
    @Autowired
    private VariableExampleUtils variableExampleUtils;

    @Override
    public void add(Long processTmpId, String allNodeInfo) {
        JSONArray jsonArray = JSONObject.parseArray(allNodeInfo);
        Map<String, List<LineInfo>> lineMap = getLineMap(jsonArray);
        Map<String, NodeInfo> nodeMap = getNodeMap(jsonArray);
        for (Map.Entry<String, NodeInfo> entry : nodeMap.entrySet()) {
            NodeInfo nodeInfo = entry.getValue();
            List<LineInfo> lineInfoList = lineMap.get(nodeInfo.getId());
            if (!CollectionUtils.isEmpty(lineInfoList)) {
                for (LineInfo lineInfo : lineInfoList) {
                    addNodeInfo(processTmpId, nodeInfo, lineInfo.getTarget(), lineInfo);
                }
            } else {
                addNodeInfo(processTmpId, nodeInfo, "END", null);
            }
        }

    }

    @Override
    public List<ProcessNodeTmpModel> getProcessNodeTmpListByProcessTmpId(Long processTmpId) {
        QueryWrapper<ProcessNodeTmpModel> processNodeTmpQueryWrapper = new QueryWrapper<>();
        processNodeTmpQueryWrapper.eq(ProcessNodeTmpModel.PROCESS_TMP_ID, processTmpId);
        return processNodeTmpMapper.selectList(processNodeTmpQueryWrapper);
    }

    @Override
    public ProcessNodeTmpModel getNextProcessNodeTmp(Long processTmpId, String sourceNodeId) {

        QueryWrapper<ProcessNodeTmpModel> processNodeTmpQueryWrapper = new QueryWrapper<>();
        processNodeTmpQueryWrapper.eq(ProcessNodeTmpModel.PROCESS_TMP_ID, processTmpId);
        //return processNodeTmpMapper.selectList(processNodeTmpQueryWrapper);

        return null;
    }

    private void addNodeInfo(Long processTmpId, NodeInfo nodeInfo, String target, LineInfo lineInfo) {
        Long currentUserAccountId = jwtUtils.getCurrentUserAccountId();
        // 插入节点信息
        ProcessNodeTmpModel processNodeTmpModel = new ProcessNodeTmpModel();
        processNodeTmpModel.setProcessTmpId(processTmpId);
        processNodeTmpModel.setSourceNodeId(nodeInfo.getId());
        processNodeTmpModel.setTargetNodeId(target);
        processNodeTmpModel.setNodeName(nodeInfo.getNodeName());
        processNodeTmpModel.setNodeFlag(nodeInfo.getNodeFlag());
        processNodeTmpModel.setNodeType(nodeInfo.getNodeType());
        processNodeTmpModel.setDescription(nodeInfo.getDescription());
        processNodeTmpModel.setCreateBy(currentUserAccountId);
        processNodeTmpModel.setCreateTime(new Date());

        // 如果是设备节点则要插入设备id
        Long equipmentMethodTmpId = nodeInfo.getEquipmentMethodTmpId();
        if (equipmentMethodTmpId != null) {
            EquipmentRespVo equipmentRespVo = equipmentService.getByMethodTmpId(equipmentMethodTmpId);
            processNodeTmpModel.setEquipmentMethodTmpId(equipmentMethodTmpId);
            processNodeTmpModel.setEquipmentId(equipmentRespVo.getId());
        }

        processNodeTmpMapper.insert(processNodeTmpModel);
        // 插入节点参数信息
        ProcessNodeParamTmpModel processNodeParamTmpModel;
        if (!CollectionUtils.isEmpty(nodeInfo.getNodeParamMap())) {
            for (Map.Entry<String, Object> entry : nodeInfo.getNodeParamMap().entrySet()) {
                Object value = entry.getValue();
                CustomNode customNode = JSONObject.parseObject(JSONObject.toJSONString(value), CustomNode.class);
                if (customNode.getValue() == null) {
                    continue;
                }
                String customNodeValue = customNode.getValue();
                log.info("--------" + customNode.getName() + ":" + customNodeValue + "--------");
                if (customNodeValue.startsWith("@")) {
                    variableExampleUtils.exist(customNodeValue);
                }
                processNodeParamTmpModel = new ProcessNodeParamTmpModel();
                processNodeParamTmpModel.setProcessTmpId(processTmpId);
                processNodeParamTmpModel.setProcessNodeTmpId(processNodeTmpModel.getId());
                processNodeParamTmpModel.setName(customNode.getName());
                processNodeParamTmpModel.setValue(customNodeValue);
                processNodeParamTmpModel.setParamType(customNode.getParamType());
                processNodeParamTmpModel.setUseType(customNode.getUseType());
                processNodeParamTmpModel.setCreateBy(currentUserAccountId);
                processNodeParamTmpModel.setCreateTime(new Date());
                processNodeParamTmpMapper.insert(processNodeParamTmpModel);
            }
            // 如果是条件节点则需要把条件节点后面线里面参数记录到每个节点上
            if (!ObjectUtils.isEmpty(lineInfo.getConditionValue())) {
                processNodeParamTmpModel = new ProcessNodeParamTmpModel();
                processNodeParamTmpModel.setProcessTmpId(processTmpId);
                processNodeParamTmpModel.setProcessNodeTmpId(processNodeTmpModel.getId());
                processNodeParamTmpModel.setName("conditionValue");
                processNodeParamTmpModel.setValue(lineInfo.getConditionValue());
                processNodeParamTmpModel.setParamType(MethodParamTypeEnum.STRING.getType());
                processNodeParamTmpModel.setUseType(NodeParamUseTypeEnum.REQ.getType());
                processNodeParamTmpModel.setCreateBy(currentUserAccountId);
                processNodeParamTmpModel.setCreateTime(new Date());
                processNodeParamTmpMapper.insert(processNodeParamTmpModel);

                processNodeParamTmpModel = new ProcessNodeParamTmpModel();
                processNodeParamTmpModel.setProcessTmpId(processTmpId);
                processNodeParamTmpModel.setProcessNodeTmpId(processNodeTmpModel.getId());
                processNodeParamTmpModel.setName("nodeId");
                processNodeParamTmpModel.setValue(target);
                processNodeParamTmpModel.setParamType(MethodParamTypeEnum.STRING.getType());
                processNodeParamTmpModel.setUseType(NodeParamUseTypeEnum.REQ.getType());
                processNodeParamTmpModel.setCreateBy(currentUserAccountId);
                processNodeParamTmpModel.setCreateTime(new Date());
                processNodeParamTmpMapper.insert(processNodeParamTmpModel);
            }
        }
        //如果是设备节点，则插入设备节点参数
        if (!ObjectUtils.isEmpty(nodeInfo.getEquipmentParams())) {
            JSONArray equipmentParams = nodeInfo.getEquipmentParams();
            for (Object equipmentParam : equipmentParams) {
                String jsonString = JSONObject.toJSONString(equipmentParam);
                EquipmentNode equipmentNode = JSONObject.parseObject(jsonString, EquipmentNode.class);

                processNodeParamTmpModel = new ProcessNodeParamTmpModel();
                String name = equipmentNode.getName();
                Object value = equipmentNode.getValue();
                String valueStr = String.valueOf(value);
                log.info("valueStr:{}", valueStr);
                if (valueStr.startsWith("@")) {
                    variableExampleUtils.exist(valueStr);
                }

                processNodeParamTmpModel.setProcessTmpId(processTmpId);
                processNodeParamTmpModel.setProcessNodeTmpId(processNodeTmpModel.getId());
                processNodeParamTmpModel.setName(name);
                processNodeParamTmpModel.setValue(valueStr);
                processNodeParamTmpModel.setParamType(equipmentNode.getParamType());
                processNodeParamTmpModel.setUseType(equipmentNode.getUseType());
                processNodeParamTmpModel.setCreateBy(currentUserAccountId);
                processNodeParamTmpModel.setCreateTime(new Date());
                processNodeParamTmpMapper.insert(processNodeParamTmpModel);
            }

        }
    }

    /**
     * 节点与节点之前的关联关系，用线计算出来
     *
     * @param jsonArray
     * @return
     */
    public Map<String, List<LineInfo>> getLineMap(JSONArray jsonArray) {
        Map<String, List<LineInfo>> map = new HashMap<>();
        for (Object str : jsonArray) {
            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(str));
            // 线的自定义参数
            JSONObject customDataJsonObj = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("data")));
            String resourceType = customDataJsonObj.getString("resourceType");
            if (resourceType.equals("commonEdge")) {
                String id = jsonObject.getString("id");
                Object source = jsonObject.get("source");
                Object target = jsonObject.get("target");
                JSONObject sourceObj = JSONObject.parseObject(JSONObject.toJSONString(source));
                JSONObject targetObj = JSONObject.parseObject(JSONObject.toJSONString(target));
                String sourceCell = sourceObj.getString("cell");
                String targetCell = targetObj.getString("cell");
                List<LineInfo> lineInfoList = map.get(sourceCell);

                String conditionValue = customDataJsonObj.getString("conditionValue");// 条件节点后面线的属性值
                // 线对象数据
                LineInfo lineInfo = new LineInfo();
                lineInfo.setId(id);
                lineInfo.setSource(sourceCell);
                lineInfo.setTarget(targetCell);
                lineInfo.setConditionValue(conditionValue);

                if (CollectionUtils.isEmpty(lineInfoList)) {
                    List<LineInfo> lineInfoList1 = new ArrayList<>();
                    lineInfoList1.add(lineInfo);
                    map.put(sourceCell, lineInfoList1);
                } else {
                    lineInfoList.add(lineInfo);
                }
            }
        }
        return map;
    }

    private Map<String, NodeInfo> getNodeMap(JSONArray jsonArray) {
        Map<String, NodeInfo> map = new HashMap<>();
        for (Object str : jsonArray) {
            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(str));

            // 获取节点自定义参数信息
            Object customData = jsonObject.get("data");
            String id = jsonObject.getString("id");
            String customDataStr = JSONObject.toJSONString(customData);
            JSONObject customDataJsonObj = JSONObject.parseObject(customDataStr);
            String resourceType = customDataJsonObj.getString("resourceType");
            String nodeName = customDataJsonObj.getString("nodeName");
            log.info("getNodeMap customDataJsonObj：{}", JSONObject.toJSONString(customDataJsonObj));
            if (resourceType.equals("commonEdge")) {
                continue;
            }
            NodeInfo nodeInfo = new NodeInfo();
            nodeInfo.setNodeFlag(CommonConstant.NODE_FLAG.ORDINARY);
            // 指令节点信息
            if (resourceType.equals("commonNode")) {
                nodeInfo.setId(id);
                nodeInfo.setNodeName(nodeName);
                nodeInfo.setNodeType(1);
                getNodeInfo(nodeName, customDataJsonObj, nodeInfo);
                map.put(id, nodeInfo);
            }
            // 系统节点
            if (resourceType.equals("systemNode")) {
                nodeInfo.setId(id);
                nodeInfo.setNodeName(nodeName);
                nodeInfo.setNodeType(0);
                getNodeInfo(nodeName, customDataJsonObj, nodeInfo);
                map.put(id, nodeInfo);
            }
            // 设备节点信息
            if (resourceType.equals("equipmentNode")) {
                nodeName = customDataJsonObj.getString("methodName");
                Long equipmentMethodTmpId = customDataJsonObj.getLong("equipmentMethodTmpId");
                Object equipmentParams = customDataJsonObj.get("methodParams");
                JSONArray objects = JSONObject.parseArray(JSONObject.toJSONString(equipmentParams));
                nodeInfo.setId(id);
                nodeInfo.setNodeType(2);
                nodeInfo.setNodeName(nodeName);
                nodeInfo.setEquipmentParams(objects);
                nodeInfo.setEquipmentMethodTmpId(equipmentMethodTmpId);
                map.put(id, nodeInfo);
            }
        }
        return map;
    }

    private void getNodeInfo(String nodeName, JSONObject customParamsJsonObj, NodeInfo nodeInfo) {

        if (nodeName.equals(ProcessNodeNameEnum.PARALLEL_NODE.getNodeName())) {
            String nodeFlag = customParamsJsonObj.getString(NodeParamConstant.PARALLEL_NODE.nodeFlag);
            String alias = customParamsJsonObj.getString(NodeParamConstant.PARALLEL_NODE.alias);
            JSONObject refObj = customParamsJsonObj.getJSONObject("ref");
            String id = "";
            if (nodeFlag.equals("end")) {
                id = refObj.getString("id");
                alias = refObj.getString("alias");
            }
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.PARALLEL_NODE.nodeFlag,
                    new CustomNode(NodeParamConstant.PARALLEL_NODE.nodeFlag, nodeFlag, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));

            nodeParamMap.put(NodeParamConstant.PARALLEL_NODE.alias,
                    new CustomNode(NodeParamConstant.PARALLEL_NODE.alias, alias, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));

            nodeParamMap.put(NodeParamConstant.PARALLEL_NODE.id,
                    new CustomNode(NodeParamConstant.PARALLEL_NODE.id, id, CommonConstant.VARIABLE_FLAG.YES,
                            NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));

            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.SELECT_NODE.getNodeName())) {
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.SELECT_NODE.conditionValue);
            String compare = customParamsJsonObj.getString(NodeParamConstant.SELECT_NODE.compare);
            Map<String, Object> nodeParamMap = new HashMap<>();

            nodeParamMap.put(NodeParamConstant.SELECT_NODE.conditionValue,
                    new CustomNode(NodeParamConstant.SELECT_NODE.conditionValue, conditionValue, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));

            nodeParamMap.put(NodeParamConstant.SELECT_NODE.compare,
                    new CustomNode(NodeParamConstant.SELECT_NODE.compare, compare, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.LOOP_NODE.getNodeName())) {
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.DELAY.getNodeName())) {
            Integer delaySecond = customParamsJsonObj.getInteger(NodeParamConstant.DELAY.delaySecond);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.DELAY.delaySecond,
                    new CustomNode(NodeParamConstant.DELAY.delaySecond, delaySecond + "", CommonConstant.VARIABLE_FLAG.YES,
                            NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.INT.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.WAIT_FOR.getNodeName())) {
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.WAIT_FOR.conditionValue);
            String conditionVariable = customParamsJsonObj.getString(NodeParamConstant.WAIT_FOR.conditionVariable);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.WAIT_FOR.conditionValue,
                    new CustomNode(NodeParamConstant.WAIT_FOR.conditionValue, conditionValue, CommonConstant.VARIABLE_FLAG.YES,
                            NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType())
            );
            nodeParamMap.put(NodeParamConstant.WAIT_FOR.conditionVariable,
                    new CustomNode(NodeParamConstant.WAIT_FOR.conditionVariable, conditionVariable, CommonConstant.VARIABLE_FLAG.YES,
                            NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.SET_VARIABLE.getNodeName())) {
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.SET_VARIABLE.conditionValue);
            String conditionVariable = customParamsJsonObj.getString(NodeParamConstant.SET_VARIABLE.conditionVariable);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.SET_VARIABLE.conditionValue,
                    new CustomNode(NodeParamConstant.SET_VARIABLE.conditionValue, conditionValue, CommonConstant.VARIABLE_FLAG.YES,
                            NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeParamMap.put(NodeParamConstant.SET_VARIABLE.conditionVariable,
                    new CustomNode(NodeParamConstant.SET_VARIABLE.conditionVariable, conditionVariable, CommonConstant.VARIABLE_FLAG.YES,
                            NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.CONDITION.getNodeName())) {
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.CONDITION.conditionValue);
            String conditionExpression = customParamsJsonObj.getString(NodeParamConstant.CONDITION.conditionExpress);
            String conditionVariable = customParamsJsonObj.getString(NodeParamConstant.CONDITION.conditionVariable);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.CONDITION.conditionVariable, new CustomNode(NodeParamConstant.CONDITION.conditionVariable, conditionVariable, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeParamMap.put(NodeParamConstant.CONDITION.conditionExpress, new CustomNode(NodeParamConstant.CONDITION.conditionExpress, conditionExpression, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeParamMap.put(NodeParamConstant.CONDITION.conditionValue, new CustomNode(NodeParamConstant.CONDITION.conditionValue, conditionValue, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.INT.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.INCREMENT.getNodeName())) {
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.INCREMENT.conditionValue);
            String conditionVariable = customParamsJsonObj.getString(NodeParamConstant.INCREMENT.conditionVariable);
            String symbols = customParamsJsonObj.getString(NodeParamConstant.INCREMENT.symbols);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.INCREMENT.conditionVariable, new CustomNode(NodeParamConstant.INCREMENT.conditionVariable, conditionVariable, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeParamMap.put(NodeParamConstant.INCREMENT.symbols, new CustomNode(NodeParamConstant.INCREMENT.symbols, symbols, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeParamMap.put(NodeParamConstant.INCREMENT.conditionValue, new CustomNode(NodeParamConstant.INCREMENT.conditionValue, conditionValue, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.INT.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.SET_PREFIX.getNodeName())) {
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.SET_PREFIX.conditionValue);
            String conditionVariable = customParamsJsonObj.getString(NodeParamConstant.SET_PREFIX.conditionVariable);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.SET_PREFIX.conditionValue, new CustomNode(NodeParamConstant.SET_PREFIX.conditionValue, conditionValue, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeParamMap.put(NodeParamConstant.SET_PREFIX.conditionVariable, new CustomNode(NodeParamConstant.SET_PREFIX.conditionVariable, conditionVariable, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.SET_SUFFIX.getNodeName())) {
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.SET_SUFFIX.conditionValue);
            String conditionVariable = customParamsJsonObj.getString(NodeParamConstant.SET_SUFFIX.conditionVariable);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.SET_SUFFIX.conditionValue, new CustomNode(NodeParamConstant.SET_SUFFIX.conditionValue, conditionValue, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeParamMap.put(NodeParamConstant.SET_SUFFIX.conditionVariable, new CustomNode(NodeParamConstant.SET_SUFFIX.conditionVariable, conditionVariable, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.PROCESS_FOR.getNodeName())) {
            String count = customParamsJsonObj.getString(NodeParamConstant.PROCESS_FOR.count);
            String processTmpId = customParamsJsonObj.getString(NodeParamConstant.PROCESS_FOR.processTmpId);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.PROCESS_FOR.count, new CustomNode(NodeParamConstant.PROCESS_FOR.count, count, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeParamMap.put(NodeParamConstant.SET_SUFFIX.conditionVariable, new CustomNode(NodeParamConstant.PROCESS_FOR.processTmpId, processTmpId, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.DATA_EXT1.getNodeName())) {
            String conditionVariable = customParamsJsonObj.getString(NodeParamConstant.DATA_EXT1.conditionVariable);
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.DATA_EXT1.conditionValue);
            String outPutVariable = customParamsJsonObj.getString(NodeParamConstant.DATA_EXT1.outPutVariable);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.DATA_EXT1.conditionVariable, new CustomNode(NodeParamConstant.DATA_EXT1.conditionVariable,
                    conditionVariable, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));

            nodeParamMap.put(NodeParamConstant.DATA_EXT1.conditionValue, new CustomNode(NodeParamConstant.DATA_EXT1.conditionValue,
                    conditionValue, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.ARRAY.getType()));

            nodeParamMap.put(NodeParamConstant.DATA_EXT1.outPutVariable, new CustomNode(NodeParamConstant.DATA_EXT1.outPutVariable,
                    outPutVariable, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.STRING.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
            return;
        }

        if (nodeName.equals(ProcessNodeNameEnum.CONFIRM.getNodeName())) {
            String conditionValue = customParamsJsonObj.getString(NodeParamConstant.CONFIRM.conditionValue);
            Map<String, Object> nodeParamMap = new HashMap<>();
            nodeParamMap.put(NodeParamConstant.CONFIRM.conditionValue, new CustomNode(NodeParamConstant.CONFIRM.conditionValue,
                    conditionValue, CommonConstant.VARIABLE_FLAG.YES, NodeParamUseTypeEnum.REQ.getType(), MethodParamTypeEnum.INT.getType()));
            nodeInfo.setNodeParamMap(nodeParamMap);
        }


    }

}
